package com.yhp.dao.impl;

import com.yhp.bean.Grade;
import com.yhp.dao.GradeDao;
import com.yhp.util.Dbutils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class GradeDaoImpl extends Dbutils implements GradeDao {
    @Override
    public List<Grade> gatGread() {
        ArrayList<Grade> list = new ArrayList<>();
        try {
            String sql = "select * from grade";
            ResultSet query = query(sql, null);
            while (query.next()){
                Grade grade = new Grade();
                grade.setGradeId(query.getInt("gradeid"));
                grade.setGradeName(query.getString("gradename"));
                list.add(grade);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            closeall();
        }


        return list;
    }
}
